package org.sapra.dep.conexion;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;


/**
 *
 * @author Luis Guerrero
 */

public class DAC {

protected static String url = "jdbc:mysql://localhost:3306/caintra?" + "user=root&password=admin";
//protected static String url = "jdbc:mysql://localhost:3306/caintra?" + "user=root&password=admin";
    protected static Connection conn;
    protected static Statement stmt;
    protected static ResultSet rs;


    protected static int Exceptions(SQLException ex) {
        System.out.println("SQLException: " + ex.getMessage());
        System.out.println("SQLState: " + ex.getSQLState());
        System.out.println("ErrorCode: " + ex.getErrorCode());
        return ex.getErrorCode();

    }

    protected static void Exceptions(Exception ex) {
         System.out.println("SQLException: " + ex.getMessage());
    }

     protected static void CloseConnexion() {
        if (rs != null) {
            try {
                rs.close();
            } catch (SQLException sqlEx) {
                System.out.println("SQLException: " + sqlEx.getMessage());
            }
            rs = null;
        }
        if (stmt != null) {
            try {
                stmt.close();
            } catch (SQLException sqlEx) {
                System.out.println("SQLException: " + sqlEx.getMessage());
            }

            stmt = null;
        }
        if (conn != null) {
            try {
                conn.close();
            } catch (SQLException sqlEx) {
                System.out.println("SQLException: " + sqlEx.getMessage());
            }
            conn = null;
        }
    }
}
